<template>
    <div class="center hover-list">
        <div
            :class="
                hoverIndex === i
                    ? 'hover-list-item hover-list-item-hover'
                    : 'hover-list-item'
            "
            v-for="(item, i) in listData"
            :key="i"
            @mouseenter="hoverIndex = i"
        >
            <div>
                <img
                    :src="hoverIndex === i ? item.hoverImg : item.img"
                    alt=""
                />
                <span>{{ item.name }}</span>
            </div>
            <p>{{ item.des }}</p>
        </div>
    </div>
</template>

<script>
export default {
    props: ["list"],
    data() {
        return {
            hoverIndex: Math.ceil((this.list.length - 1) / 2),
            listData: this.list
        };
    }
};
</script>

<style lang="less" scoped>
.hover-list {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    & div:last-of-type {
        margin-right: 0px !important;
    }
    div {
        margin-right: 40px;
    }
    margin-top: 46px;
}

.hover-list-item {
    width: 300px;
    height: 450px;
    background-color: rgba(0, 0, 0, 0.5);
    .center();
    flex-direction: column;
    justify-content: flex-start;
    > div {
        .center();
        flex-direction: column;
        height: 250px;
        width: 100%;
    }
    img {
        width: 75px;
        overflow-x: hidden;
    }
    span {
        font-size: 24px;
        margin-top: 23px;
        color: #fff;
        transition: color 0.5s;
    }
    p {
        font-size: 18px;
        color: #727272;
        width: 233px;
        line-height: 2;
        transition: color 0.5s;
        text-align: justify;
    }
    transition: width 0.5s, height 0.5s;
}

.hover-list-item-hover {
    width: 333px;
    height: 500px;
    span {
        color: @primary_color;
    }
    p {
        color: #fff;
    }
}
</style>
